import { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http';
import { Observable } from 'rxjs/Observable';

import { CommonHttpService } from './common/common-http-service';
// import {paramCase} from "@ionic/app-scripts";
@Injectable()
export class GetVideoDetailService extends CommonHttpService{


  constructor(public httpClient: HttpClient
  ) {


    super(httpClient);
    console.log(httpClient);

  }

  /**
   * 获取绘本视频详情
   */


  public getHuibenDetail(HuibenId:string): Observable<any> {
    let url = `usertemp/getWatchVideoByVCW${HuibenId}`;

    // console.log(this.get(url))
    return this.get1(url);
  }

  /**
   * 获取视频详情
   */


  public getVideoDetail(vid:string): Observable<any> {
    let url = `service/videoInfo/get-${vid}`;
    // console.log(this.get(url))
    return this.get1(url);
  }

  /**
   * 获取订单，VIP
   */
  public getOrder(vid:string): Observable<any> {
    let url = `order/buy-${vid}`;
    // console.log(this.get(url))
    return this.get1(url);
  }

  /**
   * VIP信息询价
   *
   */

  public getVipInfo(): Observable<any> {
    let url = `order/getVipInfo`;
    // console.log(this.get(url))
    return this.get1(url);
  }
  /**
   * VIP信息查询
   *
   */
  public getMyVip(): Observable<any> {
    let url = `service/myVipInfo`;
    // console.log(this.get(url))
    return this.get1(url);
  }

  public getOrderVip(): Observable<any> {
    let url = `order/buyVip`;
    // console.log(this.get(url))
    return this.get1(url);
  }

  public getNotpayOrder(orderNum: string): Observable<any> {
    let url = `order/PayNotPayOrder?order_num=`+orderNum;
    // console.log(this.get(url))
    return this.get1(url);
  }




  public wxConfig(url1:string): Observable<any> {
    let url = `wxauth/wxJsConfig`;
    // console.log(this.get(url))
    return this.get4(url, url1);
  }

  /**
   * 获取是否关注公众号
   */

  public getIsSubscribe():Observable<any>{
    let url=`service/isSubscribe`;
    return this.get1(url);
  }

  /**
   * 获取视频评论列表
   */
  public getVideoCommend(vid:string,page:string):Observable<any>{
    let url=`service/getCommonts/vid${vid}?currentPage=${page}`;
    return this.get1(url);
  }

  /**
   * 视频评论列表点赞
   * PUT /video/thumbComment/com{comment_id}
   */
  public getThumbCommend(comment_id:string):Observable<any>{
    let url=`video/thumbComment/com${comment_id}`;
    const formdata = new FormData();
    if (comment_id && comment_id != undefined) {
      formdata.append('comment_id', comment_id);
    }
    return this.put(url,null);

  }

  /**
   * 给视频评论
   * @param {string} video_id
   * @param {string} comment
   * @returns {Observable<any>}
   */
  public postCommend(video_id:string ,comment:string):Observable<any>{
    console.log('postcomment=====');
    let url=`video/addVideoSC`;
    var map = {};
    if (video_id && video_id != undefined) {
      map['video_id']= video_id;
    }
    if (comment && comment != undefined) {
      map['comment']= comment;
    }
    return this.post1(url,map);
  }


  /**
   * 给视频打分
   * @param {string} video_id
   * @param {string} comment
   * @returns {Observable<any>}
   */
  public putScore(video_id:string ,score:string):Observable<any>{
    let url=`video/scoreVideo/${video_id}/${score}`;
    // const formdata = new FormData();
    // if (video_id && video_id != undefined) {
    //   formdata.append('video_id', video_id);
    // }
    // if (score && score != undefined) {
    //   formdata.append('score', score);
    // }
    return this.put(url,null);
  }

  /**
   * 判断是否给视频评论过
   * @param {string} video_id
   * @returns {Observable<any>}
   * @constructor
   */
  public ifCommend(video_id:string):Observable<any>{
    let url=`video/isVideoComment/vc${video_id}`;
    return this.get1(url);

  }
}
